package com.neo.push.server.mongo;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;

/**
 * Created by lock on 17-8-1.
 */
public class BaseMongoService implements MongoService {


    private String host;
    private int point;
    private String databaseName;
    private MongoDatabase database;

    public void init(){
        MongoClient mongoClient = new MongoClient( host,point);
        database = mongoClient.getDatabase(databaseName);
    }


    @Override
    public MongoCollection<Document> getCollection(String collectionName) throws Exception {
        return database.getCollection(collectionName);
    }

    public void setHost(String host) {
        this.host = host;
    }

    public void setPoint(int point) {
        this.point = point;
    }


    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }
}
